package com.java123.t9.demo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class Demo3 {

	public static void main(String[] args) {
		File file = new File("C:" + File.separator + "Users" + File.separator + "kevin" + File.separator + "Desktop"
				+ File.separator + "test1.txt");
		if (file.exists()) {
			try {
				File test2 = new File("C:" + File.separator + "Users" + File.separator + "kevin" + File.separator
						+ "Desktop" + File.separator + "test3.txt");
				if (!test2.exists()) {
					test2.createNewFile();
				}
				BufferedReader rd = new BufferedReader(new FileReader(file));
				BufferedWriter wt = new BufferedWriter(new FileWriter(test2));
				String str;
				while ((str = rd.readLine()) != null) {
					wt.write(str);
					//另起一行
					wt.newLine();
				}

				// 输出流，记住刷缓存
				wt.flush();

				rd.close();
				wt.close();

			} catch (Exception e) {
				e.printStackTrace();
			}

		}

	}

}
